
/*结构体*/
typedef struct stack_node
{
	ElemType data;//存放栈的数据
	struct stack_node *next;
}stack_node,*link_pstack;

typedef struct link_stack
{
	link_pstack top;//top指针
	int count;//栈元素计数器
};

/*进栈操作*/
void push(link_stack *s,ElemType c)
{
	link_pstack p = (link_pstack)malloc(sizeof(stack_node));
	if(!p)
	{
		printf("分配栈空间失败:%s\n",strerror(errno));
		exit(0);
	}
	p->data = c;
	p->next = s->top;
	s->top = p;
	s->count++;
}

void pop(link_pstack s,ElemType *c)
{
	link_pstack p;
	if(s->top == s->base)
	{
		return;
	}
	*c = *s->top->data;
	p = s->stop;
	s->top = s->top->next;
	free(p);
	s->count--;
}

int stack_size(link_pstack s)
{
	return(s.top - s.base);
}




/*****************
应用栈链，设计逆波兰
计算器
******************/






